<!--edit by kim-->
<form method="POST" action="index.php?app=b2c&ctl=admin_business_basicmsg&act=add" class="tableform" id="newmember-edit-form">
<div class="tableform">
	<div class="division">
		<table width="100%" border="0" cellpadding="0" cellspacing="0" >
			<tbody>
				<tr><th><em class="red">*</em><{t}>用户名：<{/t}></th><td><{input type="text" name="pam_account[login_name]"  onchange="nameCheck(this)" size="20" vtype="required&&email" placeholder=$__b2c="此处请填写邮箱"|t:'b2c'}><span></span></td></tr>
				<tr><th><em class="red">*</em><{t}>密码：<{/t}></th><td><{input type="password" name="pam_account[login_password]" size="20" vtype="required"}></td></tr>
				<tr><th><em class="red">*</em><{t}>确认密码：<{/t}></th><td><{input type="password" name="pam_account[psw_confirm]" size="20" vtype="required"}></td></tr>
				<tr><th><em class="red">*</em><{t}>会员等级：<{/t}></th><td><{input type='select' name="member_lv[member_group_id]" vtype="required" options=$mem.lv.options value=$business.business }></td></tr>
			</tbody>
		</table>
	</div>
	<div class="division">
		<table>
			<tbody>
				<tr>
					<th><em class="c-red">*</em><{t}>中文全称：<{/t}></th>
					<td><{input type="text" name="business[chinese_all_name]" size="20" style="width:200px" vtype="required"}></td>
				</tr>
				<tr>
					<th><em class="c-red">*</em><{t}>英文全称：<{/t}></th>
					<td><{input type="text" name="business[english_all_name]" size="20" style="width:200px" vtype="required"}></td>
				</tr>
				<tr>
					<th><{t}>在俄公司名称：<{/t}></th>
					<td><{input type="text" name="business[russia_all_name]" size="20" style="width:200px"}></td>
				</tr>
				<tr>
					<th><{t}>公司地址：<{/t}></th>
					<td>
					<{input app=ectools type="region"  name="business[company_area]" vtype='area'}><span class="field_notice"></span>
					</td>
				</tr>
				<tr>
					<th>&nbsp;&nbsp;&nbsp;&nbsp; </th>
					<td>
					<{input  type="text"  name="business[company_addr]" size="40" }></span>
					</td>
				</tr>
			</tbody>
		</table>
	</div>
<!--第一联系人信息-->
	<div class="division">
		<tbody>
			<table>
			<tr><th><{t}>第一联系人<{/t}><th><td></td></tr>
			<tr>
			  <th><em class="c-red">*</em><{t}>联系人姓名(俄语)：<{/t}></th>
			  <td><{input type="text" name="business[company_rname1]" style="width:200px" size="20" vtype="required"}></td>
			</tr>
			<tr>
			  <th><em class="c-red">*</em><{t}>联系人姓名(汉语)：<{/t}></th>
			  <td><{input type="text" name="business[company_cname1]" style="width:200px" size="20" vtype="required"}></td>
			</tr>
			<tr>
			  <th><em class="c-red">*</em><{t}>联系人电话：<{/t}></th>
			  <td style="width:350px;">
			  <{if $phones}>
				<select name="business[phone_setting1]" id="quhao" onchange="checkPerfix(this)">
					<{foreach from=$phones item=items}>
					<option sid="<{$items.length}>" value="<{$items.area}>"><{$items.country}><{$items.area}></option>
					<{/foreach}>
				</select>
			  <{/if}>
			  <{input type="text" name="business[company_tel1]" id="mobile" style="width:110px" size="20" vtype="required" onchange="telCheck(this)"}><span></span></td>
			</tr>
			<tr>
			  <th><{t}>联系人微信：<{/t}></th>
			  <td><{input type="text" name="business[company_weixin1]" style="width:200px" size="20"}></td>
			</tr>
			</table>
		</tbody>
	</div>
<!--第二联系人信息-->
	<div class="division">
		<tbody>
			<table>
			<tr><th><{t}>第二联系人<{/t}><th><td></td></tr>
			<tr>
			  <th><{t}>联系人姓名(俄语)：<{/t}></th>
			  <td><{input type="text" name="business[company_rname2]" style="width:200px" size="20" }></td>
			</tr>
			<tr>
			  <th><{t}>联系人姓名(汉语)：<{/t}></th>
			  <td><{input type="text" name="business[company_cname2]" style="width:200px" size="20" }></td>
			</tr>
			<tr>
			  <th><{t}>联系人电话：<{/t}></th>
			  <td style="width:350px;">
			  <{if $phones}>
				<select name="business[phone_setting2]" id="quhao2" onchange="checkPerfix2(this)">
					<{foreach from=$phones item=items}>
					<option sid="<{$items.length}>" value="<{$items.area}>"><{$items.country}><{$items.area}></option>
					<{/foreach}>
				</select>
			  <{/if}>
			  <{input type="text" name="business[company_tel2]" id="mobile2" style="width:110px" size="20" onchange="telCheck2(this)"}><span></span></td>
			</tr>
			<tr>
			  <th><{t}>联系人微信：<{/t}></th>
			  <td><{input type="text" name="business[company_weixin2]" style="width:200px" size="20"}></td>
			</tr>
			<tr>
			  <th><{t}>其他联系方式：<{/t}></th>
			  <td><{input type="text" name="business[others_contact]" style="width:200px" size="20"}></td>
			</tr>
			</table>
		</tbody>
	</div>
	<div class="division">
		<tbody>
			<table>
			<tr>
				<th><{t}>出货仓库类型：<{/t}></th>
				<td><input type="radio" name="business[depot_type]" value=0><{t}>Lublino<{/t}>
				<input type="radio" name="business[depot_type]" value=1><{t}>HY仓库<{/t}>
				<input type="radio" name="business[depot_type]" value=2 checked><{t}>其他<{/t}></td>
			</tr>
			<tr>
				<th><{t}>出货仓库地址：<{/t}></th>
				<td><{input type="text" name="business[depot_addr]" style="width:200px" size="20"}></td>
			</tr>
			<tr>
				<th><{t}>Lublino店铺编号：<{/t}></th>
				<td><{input type="text" name="business[lnumber]" style="width:200px" size="20"}></td>
			</tr>
			<tr>
				<th><{t}>商检证到期日期：<{/t}></th>
				<td><{input type="date" name="business[check_time]"}></td>
			</tr>
			<tr>
				<th><{t}>是否有代理授权：<{/t}></th>
				<td><input type="radio" name="business[is_agency]" value="true"><{t}>是<{/t}>
				<input type="radio" name="business[is_agency]" value="false" checked><{t}>否<{/t}></td>
			</tr>
			<tr>
				<th><{t}>CRM客户编码：<{/t}></th>
				<td><{input type="text" name="business[crm_number]" style="width:200px" size="20" }></td>
			</tr>
			<tr>
				<th><{t}>是否为物流客户：<{/t}></th>
				<td><input type="radio" name="business[is_wuliu]" value="true"><{t}>是<{/t}>
				<input type="radio" name="business[is_wuliu]" value="false" checked><{t}>否<{/t}></td>
			</tr>
			<tr>
				<th><{t}>库存确认：<{/t}></th>
				<td><input type="radio" name="business[is_share]" value="true" checked><{t}>需要<{/t}>
				<input type="radio" name="business[is_share]" value="false"><{t}>不需要<{/t}></td>
			</tr>
			</table>
		</tbody>
	</div>
</div>
</form>
<{area inject='.mainFoot'}>
     <div class="table-action">
	<{button type="button" label=$___b2c="保存"|t:'b2c' id="newmember-edit-form-submit"}>
</div>
<{/area}>
<script>
(function(){
	var _form = $('newmember-edit-form');
	var btn =$('newmember-edit-form-submit');
	var finder = finderGroup['<{$env.get.finder_id}>'];

	_form.store('target',{
		onComplete:function(){            

		},
		onSuccess:function(response){
			var hash_res_obj = JSON.decode(response);
			if (hash_res_obj.success != undefined && hash_res_obj.success != "")
			{
				try{
					var _dialogIns = btn.getParent('.dialog').retrieve('instance');
				}catch(e){}

				if(_dialogIns)
				{
					_dialogIns.close();
					finder.refresh.delay(400,finder);
				}
			}
			else
			{
				//alert(hash_res_obj.error);
			}            
		}
	});

	btn.addEvent('click',function(){
		_form.fireEvent('submit',{stop:$empty});



	});

})();

function nameCheck(input){
	new Request({
		url:'<{link app=b2c ctl=admin_member act=namecheck_email}>',
		method:'post',
		data:input.name+'='+encodeURIComponent(input.value=input.value.trim()),
		onSuccess: function(rs) {
			rs = JSON.decode(rs);
			if(rs.error) {
				input.getNext().innerHTML = '<span class="error caution notice-inline">' +rs.error + '</span>';
			}
			else if(rs.success) {
				input.getNext().innerHTML = '<span class="success notice-inline">' +rs.success + '</span>';
			}
		}
	}).send();
}

function telCheck(input){
	var obj = $$("#quhao option:selected");
	var phone_setting = '';
	var len = '';
	if(obj && obj[0])
	{
		phone_setting = obj[0].value.replace("+","%2B");
		len = obj[0].get('sid');
	}

	new Request({
		url:'<{link app=b2c ctl=admin_operator_member act=check_tel2}>',
		method:'post',
		data:'mobile='+input.value.trim()+"&phone_setting="+phone_setting+'&len='+len,
		onSuccess: function(rs) {
			rs = JSON.decode(rs);
			if(rs.error) {
				input.getNext().innerHTML = '<span class="error caution notice-inline">' +rs.error + '</span>';
			}
			else if(rs.success) {
				input.getNext().innerHTML = '<span class="success notice-inline">' +rs.success + '</span>';
			}
		}
	}).send();
}

function telCheck2(input){
	var obj = $$("#quhao2 option:selected");
	var phone_setting = '';
	var len = '';
	if(obj && obj[0])
	{
		phone_setting = obj[0].value.replace("+","%2B");
		len = obj[0].get('sid');
	}

	new Request({
		url:'<{link app=b2c ctl=admin_operator_member act=check_tel2}>',
		method:'post',
		data:'mobile='+input.value.trim()+"&phone_setting="+phone_setting+'&len='+len,
		onSuccess: function(rs) {
			rs = JSON.decode(rs);
			if(rs.error) {
				input.getNext().innerHTML = '<span class="error caution notice-inline">' +rs.error + '</span>';
			}
			else if(rs.success) {
				input.getNext().innerHTML = '<span class="success notice-inline">' +rs.success + '</span>';
			}
		}
	}).send();
}

function checkPerfix(obj){
	var phone_setting = obj.get('value');
	var input = $('mobile');
	var mobile = input.get('value');
	var o = $$("#quhao option:selected");
	if(o && o[0])
	{
		var len = o[0].get('sid');
	}
	new Request({
		url:'<{link app=b2c ctl=admin_operator_member act=check_tel2}>',
		method:'post',
		data:'mobile='+mobile+"&phone_setting="+phone_setting+'&len='+len,
		onSuccess: function(rs) {
			rs = JSON.decode(rs);
			if(rs.error) {
				input.getNext().innerHTML = '<span class="error caution notice-inline">' +rs.error + '</span>';
			}
			else if(rs.success) {
				input.getNext().innerHTML = '<span class="success notice-inline">' +rs.success + '</span>';
			}
		}
	}).send();
}

function checkPerfix2(obj){
	var phone_setting = obj.get('value');
	var input = $('mobile2');
	var mobile = input.get('value');
	var o = $$("#quhao option:selected");
	if(o && o[0])
	{
		var len = o[0].get('sid');
	}
	new Request({
		url:'<{link app=b2c ctl=admin_operator_member act=check_tel2}>',
		method:'post',
		data:'mobile='+mobile+"&phone_setting="+phone_setting+'&len='+len,
		onSuccess: function(rs) {
			rs = JSON.decode(rs);
			if(rs.error) {
				input.getNext().innerHTML = '<span class="error caution notice-inline">' +rs.error + '</span>';
			}
			else if(rs.success) {
				input.getNext().innerHTML = '<span class="success notice-inline">' +rs.success + '</span>';
			}
		}
	}).send();
}
</script>